.class public Lcom/vividsolutions/jts/algorithm/PointLocator;
.super Ljava/lang/Object;
.source "PointLocator.java"


# instance fields
.field private boundaryRule:Lcom/vividsolutions/jts/algorithm/BoundaryNodeRule;

.field private isIn:Z

.field private numBoundaries:I


# direct methods
.method public constructor <init>()V
    .locals 1

    .line 64
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 59
    sget-object v0, Lcom/vividsolutions/jts/algorithm/BoundaryNodeRule;->ENDPOINT_BOUNDARY_RULE:Lcom/vividsolutions/jts/algorithm/BoundaryNodeRule;

    iput-object v0, p0, Lcom/vividsolutions/jts/algorithm/PointLocator;->boundaryRule:Lcom/vividsolutions/jts/algorithm/BoundaryNodeRule;

    return-void
.end method

.method private computeLocation(Lcom/vividsolutions/jts/geom/Coordinate;Lcom/vividsolutions/jts/geom/Geometry;)V
    .locals 2

    .line 120
    instance-of v0, p2, Lcom/vividsolutions/jts/geom/LineString;

    if-eqz v0, :cond_0

    .line 121
    check-cast p2, Lcom/vividsolutions/jts/geom/LineString;

    invoke-direct {p0, p1, p2}, Lcom/vividsolutions/jts/algorithm/PointLocator;->locate(Lcom/vividsolutions/jts/geom/Coordinate;Lcom/vividsolutions/jts/geom/LineString;)I

    move-result p1

    invoke-direct {p0, p1}, Lcom/vividsolutions/jts/algorithm/PointLocator;->updateLocationInfo(I)V

    goto :goto_3

    .line 123
    :cond_0
    instance-of v0, p2, Lcom/vividsolutions/jts/geom/Polygon;

    if-eqz v0, :cond_1

    .line 124
    check-cast p2, Lcom/vividsolutions/jts/geom/Polygon;

    invoke-direct {p0, p1, p2}, Lcom/vividsolutions/jts/algorithm/PointLocator;->locate(Lcom/vividsolutions/jts/geom/Coordinate;Lcom/vividsolutions/jts/geom/Polygon;)I

    move-result p1

    invoke-direct {p0, p1}, Lcom/vividsolutions/jts/algorithm/PointLocator;->updateLocationInfo(I)V

    goto :goto_3

    .line 126
    :cond_1
    instance-of v0, p2, Lcom/vividsolutions/jts/geom/MultiLineString;

    const/4 v1, 0x0

    if-eqz v0, :cond_2

    .line 127
    check-cast p2, Lcom/vividsolutions/jts/geom/MultiLineString;

    .line 128
    :goto_0
    invoke-virtual {p2}, Lcom/vividsolutions/jts/geom/GeometryCollection;->getNumGeometries()I

    move-result v0

    if-ge v1, v0, :cond_5

    .line 129
    invoke-virtual {p2, v1}, Lcom/vividsolutions/jts/geom/GeometryCollection;->getGeometryN(I)Lcom/vividsolutions/jts/geom/Geometry;

    move-result-object v0

    check-cast v0, Lcom/vividsolutions/jts/geom/LineString;

    .line 130
    invoke-direct {p0, p1, v0}, Lcom/vividsolutions/jts/algorithm/PointLocator;->locate(Lcom/vividsolutions/jts/geom/Coordinate;Lcom/vividsolutions/jts/geom/LineString;)I

    move-result v0

    invoke-direct {p0, v0}, Lcom/vividsolutions/jts/algorithm/PointLocator;->updateLocationInfo(I)V

    add-int/lit8 v1, v1, 0x1

    goto :goto_0

    .line 133
    :cond_2
    instance-of v0, p2, Lcom/vividsolutions/jts/geom/MultiPolygon;

    if-eqz v0, :cond_3

    .line 134
    check-cast p2, Lcom/vividsolutions/jts/geom/MultiPolygon;

    .line 135
    :goto_1
    invoke-virtual {p2}, Lcom/vividsolutions/jts/geom/GeometryCollection;->getNumGeometries()I

    move-result v0

    if-ge v1, v0, :cond_5

    .line 136
    invoke-virtual {p2, v1}, Lcom/vividsolutions/jts/geom/GeometryCollection;->getGeometryN(I)Lcom/vividsolutions/jts/geom/Geometry;

    move-result-object v0

    check-cast v0, Lcom/vividsolutions/jts/geom/Polygon;

    .line 137
    invoke-direct {p0, p1, v0}, Lcom/vividsolutions/jts/algorithm/PointLocator;->locate(Lcom/vividsolutions/jts/geom/Coordinate;Lcom/vividsolutions/jts/geom/Polygon;)I

    move-result v0

    invoke-direct {p0, v0}, Lcom/vividsolutions/jts/algorithm/PointLocator;->updateLocationInfo(I)V

    add-int/lit8 v1, v1, 0x1

    goto :goto_1

    .line 140
    :cond_3
    instance-of v0, p2, Lcom/vividsolutions/jts/geom/GeometryCollection;

    if-eqz v0, :cond_5

    .line 141
    new-instance v0, Lcom/vividsolutions/jts/geom/GeometryCollectionIterator;

    move-object v1, p2

    check-cast v1, Lcom/vividsolutions/jts/geom/GeometryCollection;

    invoke-direct {v0, v1}, Lcom/vividsolutions/jts/geom/GeometryCollectionIterator;-><init>(Lcom/vividsolutions/jts/geom/Geometry;)V

    .line 142
    :cond_4
    :goto_2
    invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z

    move-result v1

    if-eqz v1, :cond_5

    .line 143
    invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Lcom/vividsolutions/jts/geom/Geometry;

    if-eq v1, p2, :cond_4

    .line 145
    invoke-direct {p0, p1, v1}, Lcom/vividsolutions/jts/algorithm/PointLocator;->computeLocation(Lcom/vividsolutions/jts/geom/Coordinate;Lcom/vividsolutions/jts/geom/Geometry;)V

    goto :goto_2

    :cond_5
    :goto_3
    return-void
.end method

.method private locate(Lcom/vividsolutions/jts/geom/Coordinate;Lcom/vividsolutions/jts/geom/LineString;)I
    .locals 3

    .line 158
    invoke-virtual {p2}, Lcom/vividsolutions/jts/geom/LineString;->getCoordinates()[Lcom/vividsolutions/jts/geom/Coordinate;

    move-result-object v0

    .line 159
    invoke-virtual {p2}, Lcom/vividsolutions/jts/geom/LineString;->isClosed()Z

    move-result p2

    const/4 v1, 0x0

    if-nez p2, :cond_1

    .line 160
    aget-object p2, v0, v1

    invoke-virtual {p1, p2}, Lcom/vividsolutions/jts/geom/Coordinate;->equals(Ljava/lang/Object;)Z

    move-result p2

    const/4 v2, 0x1

    if-nez p2, :cond_0

    array-length p2, v0

    sub-int/2addr p2, v2

    aget-object p2, v0, p2

    invoke-virtual {p1, p2}, Lcom/vividsolutions/jts/geom/Coordinate;->equals(Ljava/lang/Object;)Z

    move-result p2

    if-eqz p2, :cond_1

    :cond_0
    return v2

    .line 165
    :cond_1
    invoke-static {p1, v0}, Lcom/vividsolutions/jts/algorithm/CGAlgorithms;->isOnLine(Lcom/vividsolutions/jts/geom/Coordinate;[Lcom/vividsolutions/jts/geom/Coordinate;)Z

    move-result p1

    if-eqz p1, :cond_2

    return v1

    :cond_2
    const/4 p1, 0x2

    return p1
.end method

.method private locate(Lcom/vividsolutions/jts/geom/Coordinate;Lcom/vividsolutions/jts/geom/Polygon;)I
    .locals 5

    .line 183
    invoke-virtual {p2}, Lcom/vividsolutions/jts/geom/Polygon;->isEmpty()Z

    move-result v0

    const/4 v1, 0x2

    if-eqz v0, :cond_0

    return v1

    .line 184
    :cond_0
    invoke-virtual {p2}, Lcom/vividsolutions/jts/geom/Polygon;->getExteriorRing()Lcom/vividsolutions/jts/geom/LineString;

    move-result-object v0

    check-cast v0, Lcom/vividsolutions/jts/geom/LinearRing;

    .line 186
    invoke-direct {p0, p1, v0}, Lcom/vividsolutions/jts/algorithm/PointLocator;->locateInPolygonRing(Lcom/vividsolutions/jts/geom/Coordinate;Lcom/vividsolutions/jts/geom/LinearRing;)I

    move-result v0

    if-ne v0, v1, :cond_1

    return v1

    :cond_1
    const/4 v2, 0x1

    if-ne v0, v2, :cond_2

    return v2

    :cond_2
    const/4 v0, 0x0

    const/4 v3, 0x0

    .line 190
    :goto_0
    invoke-virtual {p2}, Lcom/vividsolutions/jts/geom/Polygon;->getNumInteriorRing()I

    move-result v4

    if-ge v3, v4, :cond_5

    .line 191
    invoke-virtual {p2, v3}, Lcom/vividsolutions/jts/geom/Polygon;->getInteriorRingN(I)Lcom/vividsolutions/jts/geom/LineString;

    move-result-object v4

    check-cast v4, Lcom/vividsolutions/jts/geom/LinearRing;

    .line 192
    invoke-direct {p0, p1, v4}, Lcom/vividsolutions/jts/algorithm/PointLocator;->locateInPolygonRing(Lcom/vividsolutions/jts/geom/Coordinate;Lcom/vividsolutions/jts/geom/LinearRing;)I

    move-result v4

    if-nez v4, :cond_3

    return v1

    :cond_3
    if-ne v4, v2, :cond_4

    return v2

    :cond_4
    add-int/lit8 v3, v3, 0x1

    goto :goto_0

    :cond_5
    return v0
.end method

.method private locateInPolygonRing(Lcom/vividsolutions/jts/geom/Coordinate;Lcom/vividsolutions/jts/geom/LinearRing;)I
    .locals 1

    .line 173
    invoke-virtual {p2}, Lcom/vividsolutions/jts/geom/LineString;->getCoordinates()[Lcom/vividsolutions/jts/geom/Coordinate;

    move-result-object v0

    invoke-static {p1, v0}, Lcom/vividsolutions/jts/algorithm/CGAlgorithms;->isOnLine(Lcom/vividsolutions/jts/geom/Coordinate;[Lcom/vividsolutions/jts/geom/Coordinate;)Z

    move-result v0

    if-eqz v0, :cond_0

    const/4 p1, 0x1

    return p1

    .line 176
    :cond_0
    invoke-virtual {p2}, Lcom/vividsolutions/jts/geom/LineString;->getCoordinates()[Lcom/vividsolutions/jts/geom/Coordinate;

    move-result-object p2

    invoke-static {p1, p2}, Lcom/vividsolutions/jts/algorithm/CGAlgorithms;->isPointInRing(Lcom/vividsolutions/jts/geom/Coordinate;[Lcom/vividsolutions/jts/geom/Coordinate;)Z

    move-result p1

    if-eqz p1, :cond_1

    const/4 p1, 0x0

    return p1

    :cond_1
    const/4 p1, 0x2

    return p1
.end method

.method private updateLocationInfo(I)V
    .locals 1

    const/4 v0, 0x1

    if-nez p1, :cond_0

    .line 152
    iput-boolean v0, p0, Lcom/vividsolutions/jts/algorithm/PointLocator;->isIn:Z

    :cond_0
    if-ne p1, v0, :cond_1

    .line 153
    iget p1, p0, Lcom/vividsolutions/jts/algorithm/PointLocator;->numBoundaries:I

    add-int/2addr p1, v0

    iput p1, p0, Lcom/vividsolutions/jts/algorithm/PointLocator;->numBoundaries:I

    :cond_1
    return-void
.end method


# virtual methods
.method public locate(Lcom/vividsolutions/jts/geom/Coordinate;Lcom/vividsolutions/jts/geom/Geometry;)I
    .locals 2

    .line 98
    invoke-virtual {p2}, Lcom/vividsolutions/jts/geom/Geometry;->isEmpty()Z

    move-result v0

    const/4 v1, 0x2

    if-eqz v0, :cond_0

    return v1

    .line 100
    :cond_0
    instance-of v0, p2, Lcom/vividsolutions/jts/geom/LineString;

    if-eqz v0, :cond_1

    .line 101
    check-cast p2, Lcom/vividsolutions/jts/geom/LineString;

    invoke-direct {p0, p1, p2}, Lcom/vividsolutions/jts/algorithm/PointLocator;->locate(Lcom/vividsolutions/jts/geom/Coordinate;Lcom/vividsolutions/jts/geom/LineString;)I

    move-result p1

    return p1

    .line 103
    :cond_1
    instance-of v0, p2, Lcom/vividsolutions/jts/geom/Polygon;

    if-eqz v0, :cond_2

    .line 104
    check-cast p2, Lcom/vividsolutions/jts/geom/Polygon;

    invoke-direct {p0, p1, p2}, Lcom/vividsolutions/jts/algorithm/PointLocator;->locate(Lcom/vividsolutions/jts/geom/Coordinate;Lcom/vividsolutions/jts/geom/Polygon;)I

    move-result p1

    return p1

    :cond_2
    const/4 v0, 0x0

    .line 107
    iput-boolean v0, p0, Lcom/vividsolutions/jts/algorithm/PointLocator;->isIn:Z

    .line 108
    iput v0, p0, Lcom/vividsolutions/jts/algorithm/PointLocator;->numBoundaries:I

    .line 109
    invoke-direct {p0, p1, p2}, Lcom/vividsolutions/jts/algorithm/PointLocator;->computeLocation(Lcom/vividsolutions/jts/geom/Coordinate;Lcom/vividsolutions/jts/geom/Geometry;)V

    .line 110
    iget-object p1, p0, Lcom/vividsolutions/jts/algorithm/PointLocator;->boundaryRule:Lcom/vividsolutions/jts/algorithm/BoundaryNodeRule;

    iget p2, p0, Lcom/vividsolutions/jts/algorithm/PointLocator;->numBoundaries:I

    invoke-interface {p1, p2}, Lcom/vividsolutions/jts/algorithm/BoundaryNodeRule;->isInBoundary(I)Z

    move-result p1

    if-eqz p1, :cond_3

    const/4 p1, 0x1

    return p1

    .line 112
    :cond_3
    iget p1, p0, Lcom/vividsolutions/jts/algorithm/PointLocator;->numBoundaries:I

    if-gtz p1, :cond_5

    iget-boolean p1, p0, Lcom/vividsolutions/jts/algorithm/PointLocator;->isIn:Z

    if-eqz p1, :cond_4

    goto :goto_0

    :cond_4
    return v1

    :cond_5
    :goto_0
    return v0
.end method
